package utils;
/*
@ClassName:     DruidTest
@Author:        YangXu
@Need:          
@Date:          2022/4/27
@Time:          2022-04-27 10:21
*/

//


import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class DruidTest {
    public Connection getConnection() throws Exception {
        Properties properties = new Properties();
        // 加载配置文件
        InputStream is = DruidTest.class.getClassLoader().getResourceAsStream("druid.properties");
        properties.load(is);
        // 获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        // 获取连接对象
//      Connection connection = dataSource.getConnection();
        DB db = new DB();
        Connection connection = db.getConnection();
        return connection;
    }

    public static void main(String[] args) throws Exception {
        DruidTest druidTest = new DruidTest();
        Connection connection = druidTest.getConnection();
        System.out.println(connection);
    }
}
/*

 */